﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using XnaCanvas;
using color = Microsoft.Xna.Framework.Color;
using matrix = Microsoft.Xna.Framework.Matrix;

namespace Test.Scenes {
    public partial class XnaObj2Test1 : UserControl {
        public XnaObj2Test1() {
            InitializeComponent();
            this.Loaded += XnaObj2Test1_Loaded;
        }
        XSence xs;
        XObj2 xo1, xo2, xo3;
        void XnaObj2Test1_Loaded(object sender, RoutedEventArgs e) {
            xs = this.xcanvas.Children[xcanvas.Trigger.Csn];
            xs.diffuseColor = color.Black;
            xs.InitialCamera(aspectRedio: 5 / 3);
            xo1 = new XObj2();
            xo2 = new XObj2();
            xo3 = new XObj2();
            //xo1 = new XObj2(Microsoft.Xna.Framework.Graphics.PrimitiveType.LineStrip);
            xs.Add("aaa", xo1);
            xs.Add("aa2", xo2);
            xs.Add("rectangle", xo3);
            xs.Add("polygon", new XObj2());
            var circle2 = xs.Add("circle2", new XObj2()) as XObj2;
            xo1.SetColor(250, 250, 200, 200);
            xo2.SetColor(250, 250, 200, 200);
            xo3.SetColor(250, 50, 10, 200);
            circle2.SetColor(150, 0, 10, 200);
            xs["polygon"].SetColor(0, 250, 0, 200);
            xo1.LoadCircleBorder();
            xo2.LoadEllipseBorder();
            xo3.LoadRectangleBorder();
            xs.Get<XObj2>("polygon").LoadPolygonBorder();
            circle2.LoadPolygonByIndex(sideCount: 7);
            var ps = XObject.Get2(-.5f, -.5f, .5f, -.5f, 0, .5f);
            //circle2.LoadTrangleBorderByIndex(ps[0],ps[1],ps[2]);
            //circle2.LoadRectangleByIndex();
            circle2.World *= matrix.CreateTranslation(2, 2, 0);
            xcanvas.Begin();
        }
    }
}
